package com.ymt.bpm.engine.bpmn;

import java.util.Iterator;

import javax.xml.XMLConstants;
import javax.xml.namespace.NamespaceContext;

public class BpmnNamespaceContext implements NamespaceContext {

	@Override
	public String getNamespaceURI(String prefix) {
		if (prefix == null) {
            throw new IllegalArgumentException("No prefix provided!");
        } else if (prefix.equals(XMLConstants.DEFAULT_NS_PREFIX)) {
            return "http://www.omg.org/spec/BPMN/20100524/MODEL";
        } else if (prefix.equals("bpmn2")) {
            return "http://www.omg.org/spec/BPMN/20100524/MODEL";
        } else if (prefix.equals("bpmndi")) {
            return "http://www.omg.org/spec/BPMN/20100524/DI";
        } else if (prefix.equals("dc")) {
            return "http://www.omg.org/spec/DD/20100524/DI";
        } else if (prefix.equals("di")) {
            return "http://www.omg.org/spec/DD/20100524/DC";
        } else if (prefix.equals("omgdc")) {
            return "http://www.omg.org/spec/DD/20100524/DC";
        } else if (prefix.equals("omgdi")) {
            return "http://www.omg.org/spec/DD/20100524/DI";
        } else {
            return XMLConstants.NULL_NS_URI;
        }
	}

	@Override
	public String getPrefix(String namespaceURI) {
		if (namespaceURI == null) {
            throw new IllegalArgumentException("No namespaceURI provided!");
        } else if (namespaceURI.equals("http://www.omg.org/spec/BPMN/20100524/MODEL")) {
            return "bpmn2";
        } else if (namespaceURI.equals("http://www.omg.org/spec/BPMN/20100524/DI")) {
            return "bpmndi";
        } else if (namespaceURI.equals("http://www.omg.org/spec/DD/20100524/DC")) {
            return "dc";
        } else if (namespaceURI.equals("http://www.omg.org/spec/DD/20100524/DC")) {
            return "omgdc";
        } else if (namespaceURI.equals("http://www.omg.org/spec/DD/20100524/DI")) {
            return "omgdi";
        }
		return XMLConstants.DEFAULT_NS_PREFIX;
	}

	@SuppressWarnings("rawtypes")
	@Override
	public Iterator getPrefixes(String namespaceURI) {
		return null;
	}

}
